package com.yanqu.road.server.manger.activity.recycle;

import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.entity.activity.ActivityItemRecycleData;
import com.yanqu.road.entity.activity.diggold.config.DigGoldConfig;
import com.yanqu.road.entity.enums.eActivityType;
import com.yanqu.road.entity.player.UserBagItem;
import com.yanqu.road.server.manger.activity.ActivityMgr;
import com.yanqu.road.server.manger.activity.diggold.DigGoldMgr;

import java.util.ArrayList;
import java.util.List;

public class DigGoldRecycleStrategy extends AbstractItemRecycleStrategy{
    @Override
    public void markNeedRecycleItem() {
        ActivityInfo activityInfo = DigGoldMgr.getActivityInfo();
        if (ActivityMgr.activityInShowTime(activityInfo)) {
            DigGoldConfig config = DigGoldMgr.getConfig();
            if (config != null){
                long recycleTime = activityInfo.getEndTime() * 1000L + gapTime;

                int digItemId = config.getDigItemId();
                int drillItemId = config.getDrillItemId();
                int bombItemId = config.getBombItemId();

                int scoreItemId = config.getScoreItemId();

                //标记铲子道具
                List<String> paramList = new ArrayList<>();
                paramList.add(String.valueOf(digItemId));
                paramList.add(String.valueOf(scoreItemId));
                paramList.add("0");
                paramList.add(activityInfo.getActivityName());
                ActivityItemRecycleMgr.addRecycleItemData(digItemId, activityType, 1, recycleTime, paramList);

                //清空钻头 炸弹
                ActivityItemRecycleMgr.addRecycleItemData(drillItemId, activityType, 2, recycleTime, new ArrayList<>());
                ActivityItemRecycleMgr.addRecycleItemData(bombItemId, activityType, 2, recycleTime, new ArrayList<>());

            }
        }
    }

    @Override
    protected void initActivityType() {
        activityType = eActivityType.DigGold.getValue();
    }

    @Override
    protected void doRecycle(long userId, ActivityItemRecycleData data) {
        if (data.getRecycleType() == 1){
            item2Score(userId, data);
        }
        else if (data.getRecycleType() == 2) {
            UserBagItem item = getUserBagItem(userId, data.getItemId());
            if (item != null && item.getNum() > 0) {
                removeItem(item);
            }
        }
    }

    @Override
    public boolean isActivityRunning() {
        return false;
    }
}
